package com.cskaoyan.catmall.controller.background;

import com.cskaoyan.catmall.model.vo.BaseRespVo;
import com.cskaoyan.catmall.model.vo.GoodsStaticsVo;
import com.cskaoyan.catmall.model.vo.OrderStaticicsVo;
import com.cskaoyan.catmall.model.vo.UserStatisticsVo;
import com.cskaoyan.catmall.service.StatisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;



/**
 * 创建日期: 2022-01-07-17-46
 * author : XGQ
 * description: 统计报表
 */
@RestController
@RequestMapping("admin/stat")
public class StatisticsController {

    @Autowired
    StatisticsService statisticsService;

    /**
     * @description 用户统计
     * @author XGQ
     * @date 2022/01/08 15:04
     * @param
     * @return com.cskaoyan.catmall.model.vo.BaseRespVo<com.cskaoyan.catmall.model.vo.UserStatisticsVo>
     */
    @GetMapping("user")
    public BaseRespVo<UserStatisticsVo> getUserStatistics(){
        UserStatisticsVo userStatistics = statisticsService.selectAllByUser();
        return BaseRespVo.ok(userStatistics);
    }
    /**
     * @description 订单统计
     * @author XGQ
     * @date 2022/01/08 14:56
     * @param
     * @return com.cskaoyan.catmall.model.vo.BaseRespVo<com.cskaoyan.catmall.model.vo.OrderStaticicsVo>
     */
    @GetMapping("order")
    public BaseRespVo<OrderStaticicsVo> getOrderStatistics(){
        OrderStaticicsVo orderStaticics = statisticsService.selectAllByOrder();
        return BaseRespVo.ok(orderStaticics);
    }

    /**
     * @description 商品统计
     * @author XGQ
     * @date 2022/01/08 15:04
     * @param
     * @return com.cskaoyan.catmall.model.vo.BaseRespVo<com.cskaoyan.catmall.model.vo.GoodsStaticsVo>
     */
    @GetMapping("goods")
    public BaseRespVo<GoodsStaticsVo> getGoodsStatistics(){
        GoodsStaticsVo goodsStatics = statisticsService.selectAllByGoods();
        return BaseRespVo.ok(goodsStatics);
    }
}
